#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int myAtoi(char* s);

int main()
{
	return 0;
}

int myAtoi(char* s)
{
	int idx = 0;
	while (s[idx] && s[idx] == ' ')
		idx++;
	if (!s[idx])
		return 0;

	bool isNeg = false;
	switch (s[idx]) {
	case '-':
		isNeg = true;
	case '+':
		idx++;
	}
	if (s[idx] < '0' || s[idx] > '9')
		return 0;

	int ans = 0;
	while (s[idx] && s[idx] >= '0' && s[idx] <= '9') {
		int num = s[idx++] - '0';
		if (ans > (INT_MAX - num) / 10)
			return isNeg ? INT_MIN : INT_MAX;
		ans = ans * 10 + num;
	}
	return isNeg ? -ans : ans;
}
